﻿@model SimpleTaskManager.Domain.Entities.Task

@using (Html.BeginForm("AssignPeople", "Task", FormMethod.Post, new { id = "PeopleForm" }))
{
    int i = 0;
    @Html.ValidationSummary(true)

    foreach (SimpleTaskManager.Domain.Entities.User user in ViewBag.UserList)
    {
        bool isChecked = (Model.Group.Any(u => u.UserID.Equals(user.UserID))); 
        <div>
            @if(isChecked)
            {
                 <input type="checkbox" value="@user.UserID.ToString()" name="users" id="@("user_"+i.ToString())" checked="checked" />
            }
            else
            {
                 <input type="checkbox" value="@user.UserID.ToString()" name="users" id="@("user_"+i.ToString())"/>
            }
            <label for="@("user_" + i.ToString())" >@(user.FirstName + " " + user.LastName)</label>
        </div>
        i++;
    }
}
